
<!DOCTYPE html>

<html>
  
<!-- Mirrored from docs.sympy.org/latest/modules/physics/units/dimensions.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:27:49 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

    <title>Dimensions and dimension systems &#8212; SymPy 1.9 documentation</title>
    <link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../../../_static/default.css" />
    <link rel="stylesheet" type="text/css" href="../../../_static/graphviz.css" />
    <link rel="stylesheet" type="text/css" href="../../../_static/plot_directive.css" />
    <link rel="stylesheet" type="text/css" href="../../../../../live.sympy.org/static/live-core.css" />
    <link rel="stylesheet" type="text/css" href="../../../../../live.sympy.org/static/live-autocomplete.css" />
    <link rel="stylesheet" type="text/css" href="../../../../../live.sympy.org/static/live-sphinx.css" />
    
    <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
    <script src="../../../_static/jquery.js"></script>
    <script src="../../../_static/underscore.js"></script>
    <script src="../../../_static/doctools.js"></script>
    <script src="../../../../../live.sympy.org/static/utilities.js"></script>
    <script src="../../../../../live.sympy.org/static/external/classy.js"></script>
    <script src="../../../../../live.sympy.org/static/live-core.js"></script>
    <script src="../../../../../live.sympy.org/static/live-autocomplete.js"></script>
    <script src="../../../../../live.sympy.org/static/live-sphinx.js"></script>
    
    <link rel="shortcut icon" href="../../../_static/sympy-notailtext-favicon.ico"/>
    <link href="dimensions.html" rel="canonical" />
    
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" />
    <link rel="next" title="Unit prefixes" href="prefixes.html" />
    <link rel="prev" title="Examples" href="examples.html" /> 
  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="prefixes.html" title="Unit prefixes"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="examples.html" title="Examples"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../index.html" >Physics</a> &#187;</li>
          <li class="nav-item nav-item-3"><a href="index.html" accesskey="U">Unit systems</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Dimensions and dimension systems</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="module-sympy.physics.units.dimensions">
<span id="dimensions-and-dimension-systems"></span><h1>Dimensions and dimension systems<a class="headerlink" href="#module-sympy.physics.units.dimensions" title="Permalink to this headline">¶</a></h1>
<p>Definition of physical dimensions.</p>
<p>Unit systems will be constructed on top of these dimensions.</p>
<p>Most of the examples in the doc use MKS system and are presented from the
computer point of view: from a human point, adding length to time is not legal
in MKS but it is in natural system; for a computer in natural system there is
no time dimension (but a velocity dimension instead) - in the basis - so the
question of adding time to length has no meaning.</p>
<dl class="py class">
<dt class="sig sig-object py" id="sympy.physics.units.dimensions.Dimension">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.physics.units.dimensions.</span></span><span class="sig-name descname"><span class="pre">Dimension</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">symbol</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/physics/units/dimensions.py#L91-L303"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.physics.units.dimensions.Dimension" title="Permalink to this definition">¶</a></dt>
<dd><p>This class represent the dimension of a physical quantities.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">Dimension</span></code> constructor takes as parameters a name and an optional
symbol.</p>
<p>For example, in classical mechanics we know that time is different from
temperature and dimensions make this difference (but they do not provide
any measure of these quantites.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.physics.units</span> <span class="kn">import</span> <span class="n">Dimension</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">length</span> <span class="o">=</span> <span class="n">Dimension</span><span class="p">(</span><span class="s1">&#39;length&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">length</span>
<span class="go">Dimension(length)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">time</span> <span class="o">=</span> <span class="n">Dimension</span><span class="p">(</span><span class="s1">&#39;time&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">time</span>
<span class="go">Dimension(time)</span>
</pre></div>
</div>
<p>Dimensions can be composed using multiplication, division and
exponentiation (by a number) to give new dimensions. Addition and
subtraction is defined only when the two objects are the same dimension.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">velocity</span> <span class="o">=</span> <span class="n">length</span> <span class="o">/</span> <span class="n">time</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">velocity</span>
<span class="go">Dimension(length/time)</span>
</pre></div>
</div>
<p>It is possible to use a dimension system object to get the dimensionsal
dependencies of a dimension, for example the dimension system used by the
SI units convention can be used:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">sympy.physics.units.systems.si</span> <span class="kn">import</span> <span class="n">dimsys_SI</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dimsys_SI</span><span class="o">.</span><span class="n">get_dimensional_dependencies</span><span class="p">(</span><span class="n">velocity</span><span class="p">)</span>
<span class="go">{&#39;length&#39;: 1, &#39;time&#39;: -1}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">length</span> <span class="o">+</span> <span class="n">length</span>
<span class="go">Dimension(length)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">l2</span> <span class="o">=</span> <span class="n">length</span><span class="o">**</span><span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">l2</span>
<span class="go">Dimension(length**2)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dimsys_SI</span><span class="o">.</span><span class="n">get_dimensional_dependencies</span><span class="p">(</span><span class="n">l2</span><span class="p">)</span>
<span class="go">{&#39;length&#39;: 2}</span>
</pre></div>
</div>
<dl class="py method">
<dt class="sig sig-object py" id="sympy.physics.units.dimensions.Dimension.has_integer_powers">
<span class="sig-name descname"><span class="pre">has_integer_powers</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dim_sys</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/physics/units/dimensions.py#L290-L303"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.physics.units.dimensions.Dimension.has_integer_powers" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if the dimension object has only integer powers.</p>
<p>All the dimension powers should be integers, but rational powers may
appear in intermediate steps. This method may be used to check that the
final result is well-defined.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.physics.units.dimensions.Dimension.is_dimensionless">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_dimensionless</span></span><a class="headerlink" href="#sympy.physics.units.dimensions.Dimension.is_dimensionless" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if the dimension object really has a dimension.</p>
<p>A dimension should have at least one component with non-zero power.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="sympy.physics.units.dimensions.DimensionSystem">
<em class="property"><span class="pre">class</span> </em><span class="sig-prename descclassname"><span class="pre">sympy.physics.units.dimensions.</span></span><span class="sig-name descname"><span class="pre">DimensionSystem</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">base_dims</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">derived_dims</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">[]</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dimensional_dependencies</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">{}</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">descr</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/physics/units/dimensions.py#L311-L688"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.physics.units.dimensions.DimensionSystem" title="Permalink to this definition">¶</a></dt>
<dd><p>DimensionSystem represents a coherent set of dimensions.</p>
<p>The constructor takes three parameters:</p>
<ul class="simple">
<li><p>base dimensions;</p></li>
<li><p>derived dimensions: these are defined in terms of the base dimensions
(for example velocity is defined from the division of length by time);</p></li>
<li><p>dependency of dimensions: how the derived dimensions depend
on the base dimensions.</p></li>
</ul>
<p>Optionally either the <code class="docutils literal notranslate"><span class="pre">derived_dims</span></code> or the <code class="docutils literal notranslate"><span class="pre">dimensional_dependencies</span></code>
may be omitted.</p>
<dl class="py property">
<dt class="sig sig-object py" id="sympy.physics.units.dimensions.DimensionSystem.can_transf_matrix">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">can_transf_matrix</span></span><a class="headerlink" href="#sympy.physics.units.dimensions.DimensionSystem.can_transf_matrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Useless method, kept for compatibility with previous versions.</p>
<p>DO NOT USE.</p>
<p>Return the canonical transformation matrix from the canonical to the
base dimension basis.</p>
<p>It is the inverse of the matrix computed with inv_can_transf_matrix().</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.physics.units.dimensions.DimensionSystem.dim">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">dim</span></span><a class="headerlink" href="#sympy.physics.units.dimensions.DimensionSystem.dim" title="Permalink to this definition">¶</a></dt>
<dd><p>Useless method, kept for compatibility with previous versions.</p>
<p>DO NOT USE.</p>
<p>Give the dimension of the system.</p>
<p>That is return the number of dimensions forming the basis.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.physics.units.dimensions.DimensionSystem.dim_can_vector">
<span class="sig-name descname"><span class="pre">dim_can_vector</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dim</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/physics/units/dimensions.py#L626-L638"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.physics.units.dimensions.DimensionSystem.dim_can_vector" title="Permalink to this definition">¶</a></dt>
<dd><p>Useless method, kept for compatibility with previous versions.</p>
<p>DO NOT USE.</p>
<p>Dimensional representation in terms of the canonical base dimensions.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.physics.units.dimensions.DimensionSystem.dim_vector">
<span class="sig-name descname"><span class="pre">dim_vector</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dim</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/physics/units/dimensions.py#L640-L649"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.physics.units.dimensions.DimensionSystem.dim_vector" title="Permalink to this definition">¶</a></dt>
<dd><p>Useless method, kept for compatibility with previous versions.</p>
<p>DO NOT USE.</p>
<p>Vector representation in terms of the base dimensions.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.physics.units.dimensions.DimensionSystem.inv_can_transf_matrix">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">inv_can_transf_matrix</span></span><a class="headerlink" href="#sympy.physics.units.dimensions.DimensionSystem.inv_can_transf_matrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Useless method, kept for compatibility with previous versions.</p>
<p>DO NOT USE.</p>
<p>Compute the inverse transformation matrix from the base to the
canonical dimension basis.</p>
<p>It corresponds to the matrix where columns are the vector of base
dimensions in canonical basis.</p>
<p>This matrix will almost never be used because dimensions are always
defined with respect to the canonical basis, so no work has to be done
to get them in this basis. Nonetheless if this matrix is not square
(or not invertible) it means that we have chosen a bad basis.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.physics.units.dimensions.DimensionSystem.is_consistent">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">is_consistent</span></span><a class="headerlink" href="#sympy.physics.units.dimensions.DimensionSystem.is_consistent" title="Permalink to this definition">¶</a></dt>
<dd><p>Useless method, kept for compatibility with previous versions.</p>
<p>DO NOT USE.</p>
<p>Check if the system is well defined.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.physics.units.dimensions.DimensionSystem.is_dimensionless">
<span class="sig-name descname"><span class="pre">is_dimensionless</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dimension</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/physics/units/dimensions.py#L561-L569"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.physics.units.dimensions.DimensionSystem.is_dimensionless" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if the dimension object really has a dimension.</p>
<p>A dimension should have at least one component with non-zero power.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="sympy.physics.units.dimensions.DimensionSystem.list_can_dims">
<em class="property"><span class="pre">property</span> </em><span class="sig-name descname"><span class="pre">list_can_dims</span></span><a class="headerlink" href="#sympy.physics.units.dimensions.DimensionSystem.list_can_dims" title="Permalink to this definition">¶</a></dt>
<dd><p>Useless method, kept for compatibility with previous versions.</p>
<p>DO NOT USE.</p>
<p>List all canonical dimension names.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.physics.units.dimensions.DimensionSystem.print_dim_base">
<span class="sig-name descname"><span class="pre">print_dim_base</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dim</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/physics/units/dimensions.py#L651-L660"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.physics.units.dimensions.DimensionSystem.print_dim_base" title="Permalink to this definition">¶</a></dt>
<dd><p>Give the string expression of a dimension in term of the basis symbols.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="sympy.physics.units.dimensions.DimensionSystem.sort_dims">
<em class="property"><span class="pre">static</span> </em><span class="sig-name descname"><span class="pre">sort_dims</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dims</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/sympy/sympy/blob/00d6469eafdd4aac346a0b598184c15f2560dbe5/sympy/physics/units/dimensions.py#L505-L523"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#sympy.physics.units.dimensions.DimensionSystem.sort_dims" title="Permalink to this definition">¶</a></dt>
<dd><p>Useless method, kept for compatibility with previous versions.</p>
<p>DO NOT USE.</p>
<p>Sort dimensions given in argument using their str function.</p>
<p>This function will ensure that we get always the same tuple for a given
set of dimensions.</p>
</dd></dl>

</dd></dl>

</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../../index.html">
              <img class="logo" src="../../../_static/sympylogo.png" alt="Logo"/>
            </a></p>
  <h4>Previous topic</h4>
  <p class="topless"><a href="examples.html"
                        title="previous chapter">Examples</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="prefixes.html"
                        title="next chapter">Unit prefixes</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../../_sources/modules/physics/units/dimensions.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://docs.sympy.org/latest/search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="prefixes.html" title="Unit prefixes"
             >next</a> |</li>
        <li class="right" >
          <a href="examples.html" title="Examples"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">SymPy 1.9 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" >SymPy Modules Reference</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../index.html" >Physics</a> &#187;</li>
          <li class="nav-item nav-item-3"><a href="index.html" >Unit systems</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="#">Dimensions and dimension systems</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2021 SymPy Development Team.
      Last updated on Sep 30, 2021.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.1.2.
    </div>
  </body>

<!-- Mirrored from docs.sympy.org/latest/modules/physics/units/dimensions.html by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 15 Jan 2022 03:27:49 GMT -->
</html>